package com.yanqu.road.server.cmd.orewar.cross;

import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.orewar.OreWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Cmd(code = Protocol.S_CROSS_ORE_SYSTEM_BLOWOUT_MAIL, desc = "跨服坑位井喷发送之前的奖励")
public class CrossBlowoutRewardCmd extends AbstractCommand {

	private int activityId;

	private int groupId;
	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		OreWarProto.CrossBlowoutMailMsg crossRespMsg = OreWarProto.CrossBlowoutMailMsg.parseFrom(packet.getBytes());
		activityId = crossRespMsg.getActivityId();
		groupId = crossRespMsg.getGroupId();
		Map<Long,Map<Integer,String>> userPitRewardMap = new ConcurrentHashMap<>();
		for(OreWarProto.CrossBlowoutMailTempMsg mailMsg : crossRespMsg.getMailList()){
			if(!userPitRewardMap.containsKey(mailMsg.getUserId())){
				userPitRewardMap.put(mailMsg.getUserId(),new ConcurrentHashMap<>());
			}
			userPitRewardMap.get(mailMsg.getUserId()).put(mailMsg.getPitId(),mailMsg.getReward());
		}

		OreWarMgr.crossBlowoutRewardMail(activityId,userPitRewardMap,groupId);
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
